from typing import *


class Solution:

    def asteroidCollision(self, asteroids: List[int]) -> List[int]:
        ans = []
        for v in asteroids:
            while len(ans) > 0 and ans[-1] > 0 and v < 0 and abs(
                    ans[-1]) < abs(v):
                ans.pop()
            if len(ans) == 0 or ans[-1] < 0 or v > 0:
                ans.append(v)
            elif abs(ans[-1]) == abs(v):
                ans.pop()

        return ans